﻿using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS.Web;
using IFRS_Global;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class IFRS_WIN13_3V : PageBase
{
    #region "---------- Event -----------"

    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
        if (!IsPostBack)
        {
            ViewMenu();
            BindDDL();
            if (Request.QueryString["id"] != null)
            {
                this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
            }  
            SetControl();
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["IsRef"] != null)
            Response.Redirect("~/IFRS/WIN25_1S.aspx");
        else
            Response.Redirect("~/IFRS/WIN13_1S.aspx");
    }
    #endregion

    #region "---------- Method -----------"

    private void SetControl()
    {
        SetControlReadOnly(form_control);
    }
    private void ViewMenu()
    {
        MenuTitleBar = Resources.ifrsMenu.WIN13_3V;
    }
    private void BindData(int ID)
    {
       List<IndividualImpair> individualImpair = new List<IndividualImpair>();
        DataTable dt = new SPR_INDIVIDUALIMPAIR().SEARCH_BYID(ID);
        if (dt.Rows.Count > 0)
        {
            ConvertHelper.ConvertDataTableToObject(dt, individualImpair);
            txtDate_Transection.Text = individualImpair[0].TransactionDate.DateToString();
            ddlSourceData.SelectedValue = individualImpair[0].SourceDataID.ToString();
            txtAccountNo_ContractNumber.Text = individualImpair[0].AccountNo;
            txtDate_Payment.Text = individualImpair[0].PaymentDate.DateToString();
            txtIndividualImpairAmount.Text = individualImpair[0].IndividualImpairAmount.ToString();
            txtCollateralAmount.Text = individualImpair[0].CollateralAmount.ToString();
            txtInterestRate.Text = individualImpair[0].InterestRate.ToString();
        }
    }
    private void BindDDL()
    {
        ddlSourceData.SetData(DDL_TYPE.SourceData, "", false, true);
    }
    #endregion
}